package com.suixuan.support.util;

import java.util.Collection;

/**
 * Nanjing Zhou Su co.,Ltd
 * 
 * @Title: ConstantUtils.java
 * @Package: com.suixuan.support.util
 * @Description: 常量工具类
 * @Author: suixuan
 * @Date 2010-4-7 上午10:08:59
 * @Version V1.0
 */
public final class ConstantUtils {
	private ConstantUtils() {
	}

	public static final String EMPTY_STRING = "";

	public static final String NULL_STRING = "NULL";

	public static final String SPLIT_KEY = ",";

	public static final String SPLIT_KEY_SEMICOLON = ";";

	public static final String ROLES_ENABLED = "1";

	public static final String ROLES_DISABLED = "0";
	/**
	 * 日期格式
	 */
	public static final String DATE_FORMATE = "yyyy-MM-dd HH:mm:ss";
	/**
	 * 一天的秒值
	 */
	public static final long ONE_DAY = 86400000L;
	/**
	 * SHA形式加密
	 */
	public static final String SHA = "SHA";
	/**
	 * 文件夹名草稿箱
	 */
	public static final String DEFAULT_MAIL_FOLDER_DRAFTBOX = "default.mail.folder.draftBox";

	/**
	 * 文件夹名垃圾箱
	 */
	public static final String DEFAULT_MAIL_FOLDER_GARBAGEBOX = "default.mail.folder.garbageBox";

	/**
	 * 文件夹名收件箱
	 */
	public static final String DEFAULT_MAIL_FOLDER_INBOX = "default.mail.folder.inbox";
	/**
	 * 文件夹名收件箱
	 */
	public static final String DEFAULT_MAIL_FOLDER_INBOX_CN = "收件箱";

	/**
	 * 文件夹名发件箱
	 */
	public static final String DEFAULT_MAIL_FOLDER_RECIPIENTSBOX = "default.mail.folder.recipientsBox";

	/**
	 * 默认的邮件服务器地址
	 */
	public static final String DEFAULT_MAIL_HOST = "default.mail.host";

	/**
	 * 默认的邮件箱密码
	 */
	public static final String DEFAULT_MAIL_PASSWORD = "default.mail.password";
	/**
	 * 系统使用域名
	 */
	public static final String DEFAULT_MAIL_DOMAIN_NAME = "default.system.domainName";
	/**
	 * 系统消息默认保存天数
	 */
	public static final String DEFAULT_SYSTEM_MESSAGE_HOLD_DAYS = "default.system.message.hold.days";

	/**
	 * 系统垃圾箱消息默认保存天数
	 */
	public static final String DEFAULT_SYSTEM_MESSAGE_DRAFT_HOLD_DAYS = "default.system.message.draft.hold.days";

	/**
	 * 使用smtp协议
	 */
	public static final String MAIL_SMTP_AUTH = "mail.smtp.auth";

	/**
	 * true
	 */
	public static final String TRUE_STRING = "true";
	/**
	 * false
	 */
	public static final String FALSE_STRING = "false";
	/**
	 * 默认系统用户
	 */
	public static final String DEFAULT_SYSTEM_ADMINISTRATOR = "default.system.administrator";
	/**
	 * UTF-8编码
	 */
	public static final String ENCODER_UTF_8 = "UTF-8";

	/**
	 * GBK编码
	 */
	public static final String ENCODER_GBK = "GBK";
	/**
	 * 文件路径分割符
	 */
	public static final String FILE_PATH_SPLIT = "/";
	/**
	 * 默认的根目录文件夹名
	 */
	public static final String DEFAULT_ROOT_FOLDER_NAME = "ROOT";

	/**
	 * 默认的上传文件临时目录
	 */
	public static final String DEFAULT_UPLOAD_FOLDER_TEMP_NAME = "temp";

	/**
	 * Zip
	 */
	public static final String DEFAULT_ZIP_FILE_SUFFIX = ".zip";
	/**
	 * 上传文件地址路径
	 */
	public static final String OA_KEY_UPLOAD_PATH = "upload.path";
	/**
	 * 搜索引擎索引地址
	 */
	public static final String OA_KEY_SEARCH_INDEX_PATH = "search.index.path";

	/**
	 * 搜索引擎查询结果集关键字高亮显示覆盖字符长度
	 */
	public static final String HIGHT_LIGHT_LENGTH = "hight.light.length";

	/**
	 * pdf后缀
	 */
	public static final String POSTFIX_PDF = ".pdf";

	/**
	 * limit
	 */
	public static final String OA_PROPERTIES_LIMIT = "limit";

	/**
	 * 缺省密码
	 */
	public static final String DEFAULT_USERS_PASSOWRD = "default_users_password";
	/**
	 * OA系统中Token标识
	 */
	public static final String TOKEN_VALUE = "zs_token_value";

	/**
	 * 默认的支持建创建全文索引的文件类型
	 */
	public static final String DEFAULT_UPLOAD_FILE_SUFFIX = "default.upload.file.suffix";

	/**
	 * 默认的支持不支持创建全文索引文件类型
	 */
	public static final String DEFAULT_UPLOAD_IMAGE_SUFFIX = "default.upload.image.suffix";

	/**
	 * 默认的Word文档后缀
	 */
	public static final String DEFAULT_WORD_SUFFIX = "default.word.suffix";

	/**
	 * 默认的Excel文档后缀
	 */
	public static final String DEFAULT_EXCEL_SUFFIX = "default.excel.suffix";

	/**
	 * 默认的PPT文档后缀
	 */
	public static final String DEFAULT_PPT_SUFFIX = "default.ppt.suffix";

	/**
	 * 默认系统消息发送名
	 */
	public static final String DEFAULT_MESSAGE_SYSTEM_NAME = "系统消息";

	/**
	 * 后台验证不通过，跳转至错误页面的默认键值
	 */
	public static final String DEFAULT_PARAMETERS_ERROR_MESSAGE = "parameters_error_message";

	/**
	 * 默认的错误页面路径
	 */
	public static final String DEFAULT_ERROR_VIEW = "system/error";

	/**
	 * text/html格式contentType
	 */
	public static final String JSON_TEXT_HTML_CONTENT_TYPE = "text/html;charset=utf-8";

	/**
	 * 默认文件上传保存路径
	 */
	public static final String DEFAULT_SYSTEM_FILESPACE_PATH = "default.system.filespace.path";

	/**
	 * 默认参与全文检索的文件大小
	 */
	public static final String DEFAULT_UPLOAD_FILE_SEARCH_LENGTH = "default.upload.file.search.length";

	/**
	 * 默认单次上传文件大小
	 */
	public static final String DEFAULT_UPLOAD_FILE_MAX_LENGTH = "default.upload.file.max.length";

	/**
	 * 默认下载Mini格式Zip
	 */
	public static final String DEFAULT_DOWNLOAD_MINI_ZIP = "default.download.mini.zip";

	/**
	 * 默认下载Mini格式xls
	 */
	public static final String DEFAULT_DOWNLOAD_MINI_XLS = "default.download.mini.xls";

	/**
	 * 默认下载Mini格式doc
	 */
	public static final String DEFAULT_DOWNLOAD_MINI_DOC = "default.download.mini.doc";

	/**
	 * 默认下载Mini格式ppt
	 */
	public static final String DEFAULT_DOWNLOAD_MINI_PPT = "default.download.mini.ppt";

	/**
	 * 默认下载Mini格式mp3
	 */
	public static final String DEFAULT_DOWNLOAD_MINI_MP3 = "default.download.mini.mp3";

	/**
	 * 默认下载Mini格式jpg
	 */
	public static final String DEFAULT_DOWNLOAD_MINI_JPG = "default.download.mini.jpg";

	/**
	 * 默认下载Mini格式txt
	 */
	public static final String DEFAULT_DOWNLOAD_MINI_TXT = "default.download.mini.txt";

	/**
	 * 默认下载Mini格式gif
	 */
	public static final String DEFAULT_DOWNLOAD_MINI_GIF = "default.download.mini.gif";

	/**
	 * 默认下载Mini格式pdf
	 */
	public static final String DEFAULT_DOWNLOAD_MINI_PDF = "default.download.mini.pdf";

	/**
	 * 默认文件上传最大值
	 */
	public static final String DEFAULT_UPLOAD_MAX_SIZE = "default.upload.max.size";

	/**
	 * 默认项目根文件夹名
	 */
	public static final String DEFAULT_FILE_SPACE_PROJECT_ROOT_NAME = "[project_root]";

	/**
	 * 默认部门根文件夹名
	 */
	public static final String DEFAULT_FILE_SPACE_BRANCH_ROOT_NAME = "[branch_root]";

	/**
	 * 默认公司名
	 */
	public static final String DEFAULT_COMPANY_NAME = "default.company.name";

	/**
	 * 默认个人文件管理默认文件夹大小
	 */
	public static final String DEFAULT_UPLOAD_PERSON_CAPACITY = "default.upload.person.capacity";

	/**
	 * 默认部门或项目文件管理默认文件夹大小
	 */
	public static final String DEFAULT_UPLOAD_BRANCH_CAPACITY = "default.upload.branch.capacity";

	/**
	 * 视频文件
	 */
	public static final String FILE_VIDEO = "video";

	/**
	 * 音频文件
	 */
	public static final String FILE_AUDIO = "audio";

	/**
	 * 音频文件
	 */
	public static final String FILE_IMAGE = "image";

	/**
	 * 文本文件
	 */
	public static final String FILE_TXT = "txt";

	/**
	 * 邮件服务器主机
	 */
	public static final String DEFAULT_MAIL_SMTP_HOST = "default.mail.smtp.host";

	/**
	 * 邮件服务器地址
	 */
	public static final String DEFAULT_MAIL_VALID_SUFFIX = "default.mail.valid.suffix";

	/**
	 * 默认邮箱密码
	 */
	public static final String DEFAULT_MAIL_VALID_PASSWORD = "default.mail.valid.password";
	/**
	 * 邮件附件保存地址
	 */
	public static final String DEFAULT_MAIL_ATTACH_MENT_PATH = "default.mail.attach.ment.path";
	/**
	 * 邮件最大使用容量
	 */
	public static final String DEFAULT_MAIL_MAX_CAPACITY = "default.mail.max.capacity";

	/**
	 * 邮件头回执
	 */
	public static final String DISPOSITION_NOTIFICATION_TO = "Disposition-Notification-To";
	/**
	 * 验证码键
	 */
	public static final String CODEKEY = "code";

	public static final String MENUSANDPAGES = "menusAndPages";

	/**
	 * JMS消息服务地址及端口
	 */
	public static final String DEFAULT_JMS_SERVER = "default_jms_server";

	/**
	 * Session中用户名
	 */
	public static final String SYSTEM_USERNAME = "SYSTEM_USERNAME";
	/**
	 * 安全框架中权限前缀名
	 */
	public static final String SPRING_SECURITY_PERMISSIONS_PREFIX = "ROLE_";

	/**
	 * 实体主键
	 */
	public static final String PK = "id";

	/**
	 * MVC错误页面
	 */
	public static final String SYSTEM_ERROR_PAGE = "error/500";
	/**
	 * 进行Json数据转换时过滤的属性
	 */
	public static final String[] JSON_FILTER_PROPERTIES = { "offset", "voList", "jyOrder", "propertyName", "orderValue" };

	// public static void

	public static void main(String[] args) throws Exception {
		String s = "default.jms.server".replace('.', '_');
		System.out.println("public static final String " + s.toUpperCase() + " = \"" + s + "\";");

	}

	/**
	 * 有效的Long主键
	 * 
	 * @Title isValidLongPK
	 * @param id
	 *            主键
	 * @return True：有效 False：无效
	 * 
	 */
	public static boolean validLongPK(Long id) {
		return null != id && 0 < id;
	}

	public static String[] conversionStr(String s, String splitKey) {
		if (null == s) {
			return null;
		}
		if (null == splitKey) {
			return null;
		}
		return s.split(splitKey);
	}

	public static String joinStr(String[] s, String splitKey) {
		StringBuffer joinValue = new StringBuffer();
		for (int i = 0; i < s.length; i++) {
			if (i == s.length - 1) {
				joinValue.append(s[i]);
			} else {
				joinValue.append(s[i]).append(splitKey);
			}
		}
		return joinValue.toString();
	}

	public static String joinStr(Collection<String> s, String splitKey) {
		return joinStr(s.toArray(new String[s.size()]), splitKey);
	}
}
